<form class="form-horizontal" method="POST" action="" onsubmit="return false" >
    <input type="hidden" name="id" value="{$data.id}" />
    {:widget('common/Input/index', [$data, [
        'name' => 'agentname',
        'title' => $Think.lang.agentname,
        'placeholder' => $Think.lang.agentname,
    ]])}
    {:widget('common/Input/index', [$data, [
        'name' => 'name',
        'title' => $Think.lang.name,
        'placeholder' => $Think.lang.name,
    ]])}
    {:widget('common/Input/index', [$data, [
        'name' => 'mobile',
        'title' => $Think.lang.mobile,
        'placeholder' => $Think.lang.mobile,
    ]])}
    <div class="form-group">
        <label class="col-sm-2 control-label"><i></i>所在地址</label>
        <div class="col-sm-7">
            <div class="col-sm-3">
              {php}
                if(isset($data['province'])){
                  echo "<select name='province' id='province' class='province form-control'><option value=".$data['province'].">".$data['province1']."</option></select>";
                }else{
                  echo '<select name="province" id="province" class="province form-control" >
                    <option value="">请选择省</option>
                </select>';
                }
              {/php}
                
            </div>
            <div class="col-sm-3">
              {php}
                if(isset($data['city'])){
                  echo "<select name='city' id='city' class='city form-control'><option value=".$data['city'].">".$data['city1']."</option></select>";
                }else{
                  echo '<select name="city" id="city" class="city form-control">
                    <option value="">请选择城市</option>
                </select>';
                }
              {/php}
            </div>
            <div class="col-sm-3">
              {php}
                if(isset($data['district'])){
                    echo "<select name='district' id='district' class='istrict form-control' ><option value=".$data['district'].">".$data['district1']."</option></select>";
                  }else{
                    echo '<select name="district" id="district" class="district form-control" >
                      <option value="">请选择县区</option>
                    </select>';
                  }
              {/php}
            </div>
        </div>
    </div>
    {:widget('common/Date/index', [$data, [
        'name' => 'end_time',
        'title' => $Think.lang.end_time,
        'placeholder' => $Think.lang.end_time,
        'format' => 'YYYY-MM-DD',
    ]])}
    {:widget('common/Select/index', [$data, [
        'name' => 'status',
        'title' => $Think.lang.agent_status,
        'from' => 'selectlist',
        'fromcfg' => 'status',
    ]])}

    <div class="form-group">
        <div class="col-sm-2"></div>
        <div class="col-sm-7">
            <div class="btn-group pull-right">
                <button type="submit" class="btn btn-info pull-right submits" data-loading-text="&lt;i class='fa fa-spinner fa-spin '&gt;&lt;/i&gt; {$Think.lang.submit}">{$Think.lang.submit}</button>
            </div>
            <div class="btn-group pull-left">
                <button type="reset" class="btn btn-warning">{$Think.lang.reset}</button>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
    var pid = 0;
    $.ajax({
       url: "{:url('getCity')}",
       type: 'POST',
       dataType: 'json',
       data: {'area_pid': pid},
       success:function(data){
        console.log(data);
        var str = '';
        for(var i=0;i<data.info.length;i++){
          str+='<option value='+data.info[i]['area_id']+'>'+data.info[i]['area_name']+'</option>';
        }
        $("#province").append(str);
       },
       error:function(e){},
    });
    $('#province').change(function(event) {
        /* Act on the event */
        var pid = $(this).val();
        $.ajax({
           url: "{:url('getCity')}",
           type: 'POST',
           dataType: 'json',
           data: {'area_pid': pid},
           success:function(data){
            console.log(data);
            var str = '<option value="">请选择市</option>';
            for(var i=0;i<data.info.length;i++){
              str+='<option value='+data.info[i]['area_id']+'>'+data.info[i]['area_name']+'</option>';
            }
            $("#city").html(str);
           },
           error:function(e){},
        });
    });
    $('#city').change(function(event) {
        /* Act on the event */
        var pid = $(this).val();
        $.ajax({
           url: "{:url('getCity')}",
           type: 'POST',
           dataType: 'json',
           data: {'area_pid': pid},
           success:function(data){
            console.log(data);
            var str = '<option value="">请选择地区</option>';
            for(var i=0;i<data.info.length;i++){
              str+='<option value='+data.info[i]['area_id']+'>'+data.info[i]['area_name']+'</option>';
            }
            $("#district").html(str);
           },
           error:function(e){},
        });
    });

    console.log(123);
</script>
